// FlatListCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "codehelp.h"
#include "FlatListCtrl.h"
#include "CHDrawRect.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CFlatListCtrl

CFlatListCtrl::CFlatListCtrl()
{
	m_clrWTopLeft = RGB(255, 255, 255);
	m_clrWBottomRight = RGB(255, 255, 255);
	m_clrNTopLeft = RGB(132, 130, 132);
	m_clrNBottomRight = RGB(132, 130, 132);
}

CFlatListCtrl::~CFlatListCtrl()
{
}


BEGIN_MESSAGE_MAP(CFlatListCtrl, CHListCtrl)
	//{{AFX_MSG_MAP(CFlatListCtrl)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFlatListCtrl message handlers

LRESULT CFlatListCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	switch ( message )
	{
	case WM_PAINT:
	case WM_NCPAINT:
	case WM_ENABLE:
		CHListCtrl::WindowProc(message, wParam, lParam);
		DrawBorder();
		return 0;
	}
	
	return CHListCtrl::WindowProc(message, wParam, lParam);
}

void CFlatListCtrl::DrawBorder()
{
	HDC hDC;
	RECT rect;
	CHDrawRect::PrepareDraw(GetSafeHwnd(), hDC, rect);

	CHDrawRect::Draw3dBorder( hDC, rect, m_clrWTopLeft, m_clrWBottomRight,
			   m_clrNTopLeft, m_clrNBottomRight);

	::ReleaseDC( WindowFromDC( hDC ), hDC );
}

void CFlatListCtrl::SetBorderColor(COLORREF clrWTopLeft, COLORREF clrWBottomRight, COLORREF clrNTopLeft, COLORREF clrNBottomRight)
{
	m_clrWTopLeft = clrWTopLeft;
	m_clrWBottomRight = clrWBottomRight;
	m_clrNTopLeft = clrNTopLeft;
	m_clrNBottomRight = clrNBottomRight;
}
